
export function pay(orderInfo, spikPath = '/pages-mine/order/index', callback) {
	return new Promise(async (resolve, inject) => {
		let payJsons = JSON.parse(orderInfo.result.payJson)
		let payJson = JSON.parse((payJsons || {}).pay_info || "{}")
		uni.showLoading({
			title: '正在调起支付...',
			mask: true
		})
		let [err, res] = await uni.requestPayment({
			...payJson,
		});
		if (err) {
			resolve(false)
			inject(err)
			if (typeof callback === 'function') {
				callback(false)
			} else {
				if (payJsons.status !== 100) {
					uni.showToast({
						title: payJsons.message,
						icon: "none",
						duration: 2000
					})
				}
			}
			uni.hideLoading()
			return
		}
		resolve(true)
		if (typeof callback === 'function') {
			callback(true)
		} else {
			uni.redirectTo({
				url: spikPath
			})
		}
		uni.hideLoading()
	})

}